#ifndef LRU_LIST_H_
#define LRU_LIST_H_

namespace demon_tool
{
	struct list_node
	{
		struct list_node* prev;
		struct list_node* next;
	};

	#define LIST_INIT(list)		do{(list)->prev = (list)->next = (list);}while(0)
	#define LIST_INSERT_AFTER(node, nitem) 	do{		\
			(node)->next->prev = (nitem);					\
			(nitem)->next = (node)->next;					\
			(nitem)->prev = (node);						\
			(node)->next = (nitem); 						\
			}while(0)
	
	#define LIST_DEL(node)		do{(node)->prev->next = (node)->next;(node)->next->prev = (node)->prev;}while(0)

	#define LIST_EMPTY(node)	((node)->prev == (node))

	#define offset_of(type, member)	((long)&(((type*)0)->member))
	#define container_of(node, type, member)	((type*)(((char*)(node)) - offset_of(type, member)))
}
#endif
